home *** CD-ROM | disk | FTP | other *** search
- {
-
- Most simple example of adding a menu item to Exchange
- or Outlook.
-
- }
-
-
-
- unit ComHelloWorld1;
-
- interface
-
- uses
- Windows,
- CommCtrl,
- ExchExt;
-
-
- type
- TExchExt = class(TInterfacedObject, IExchExt, IExchExtCommands)
- protected
- { IExchExt }
- function Install(
- eecb: IEXCHEXTCALLBACK;
- mecontext: ULONG;
- ulFlags: ULONG): HResult; stdcall;
- { IExchExtCommands }
- function InstallCommands(
- eecb: IEXCHEXTCALLBACK;
- hwnd: HWND;
- hmenu: HMENU;
- var cmdidBase: UINT;
- lptbeArray: LPTBENTRY;
- ctbe: UINT;
- ulFlags: ULONG): HResult; stdcall;
- procedure InitMenu(
- eecb: IExchExtCallback); stdcall;
- function DoCommand(
- eecb: IEXCHEXTCALLBACK;
- cmdid: UINT): HResult; stdcall;
- function Help(
- eecb: IEXCHEXTCALLBACK;
- cmdid: UINT): HResult; stdcall;
- function QueryHelpText(
- cmdid: UINT;
- ulFlags: ULONG;
- lpsz: LPTSTR;
- cch: UINT): HResult; stdcall;
- function QueryButtonInfo(
- tbid: ULONG;
- itbb: UINT;
- ptbb: PTBBUTTON;
- lpsz: LPTSTR;
- cch: UINT;
- ulFlags: ULONG): HResult; stdcall;
- function ResetToolbar(
- tbid: ULONG;
- ulFlags: ULONG): HResult; stdcall;
- private
- MyCommandNum: integer;
- end;
-
-
-
- implementation
-
- uses
- Dialogs;
-
-
- { IExchExt }
-
- function TExchExt.Install(
- eecb: IEXCHEXTCALLBACK;
- mecontext: ULONG;
- ulFlags: ULONG): HResult;
- var
- ulBuildVersion: ULONG;
- begin
- { make sure this is the right version... }
- eecb.GetVersion(ulBuildVersion, EECBGV_GETBUILDVERSION);
- if (EECBGV_BUILDVERSION_MAJOR <> (ulBuildVersion and EECBGV_BUILDVERSION_MAJOR_MASK)) then begin
- Result := S_FALSE;
- Exit;
- end;
-
- { in which context(s) do we want to show up? }
- case mecontext of
- EECONTEXT_VIEWER: Result := S_OK;
- else
- Result := S_FALSE;
- end; { of case }
-
- end;
-
-
-
- { IExchExtCommands }
-
- function TExchExt.InstallCommands(
- eecb: IEXCHEXTCALLBACK;
- hwnd: HWND;
- hmenu: HMENU;
- var cmdidBase: UINT;
- lptbeArray: LPTBENTRY;
- ctbe: UINT;
- ulFlags: ULONG): HResult;
- var
- r: HResult;
- hMenuTools: Windows.HMENU;
- begin
- r := eecb.GetMenuPos(EECMDID_ToolsOptions, hMenuTools, nil, nil, 0);
- if r <> S_OK then begin
- Result := S_FALSE;
- Exit;
- end;
-
- // add a menu separator
- AppendMenu(
- hMenuTools,
- MF_SEPARATOR,
- 0,
- nil);
-
- // add our extension command
- MyCommandNum := cmdidBase;
- AppendMenu(
- hMenuTools,
- MF_BYPOSITION and MF_STRING,
- MyCommandNum,
- 'Hello World 1');
- Inc(cmdidBase);
-
- Result := S_OK;
- end;
-
-
- procedure TExchExt.InitMenu(
- eecb: IExchExtCallback);
- begin
- // do nothing
- end;
-
-
- function TExchExt.DoCommand(
- eecb: IEXCHEXTCALLBACK;
- cmdid: UINT): HResult;
- begin
- if cmdid = MyCommandNum
- then begin
- ShowMessage('Hello World 1!');
- Result := S_OK;
- end
- else
- Result := S_FALSE;
- end;
-
-
- function TExchExt.Help(
- eecb: IEXCHEXTCALLBACK;
- cmdid: UINT): HResult;
- begin
- if (cmdid = MyCommandNum)
- then begin
- ShowMessage('Sorry, my boss didn''t schedule time to implement a help file...');
- Result := S_OK;
- end
- else
- Result := S_FALSE;
- end;
-
-
- function TExchExt.QueryHelpText(
- cmdid: UINT;
- ulFlags: ULONG;
- lpsz: LPTSTR;
- cch: UINT): HResult;
- const
- HelpMsgHelloWorld:PChar = 'Click to say hello';
- begin
- if (cmdid = MyCommandNum) and ((ulFlags and EECQHT_STATUS) <> 0)
- then begin
- lstrcpyn(lpsz, HelpMsgHelloWorld, cch);
- Result := S_OK;
- end
- else
- Result := S_FALSE;
- end;
-
-
- function TExchExt.QueryButtonInfo(
- tbid: ULONG;
- itbb: UINT;
- ptbb: PTBBUTTON;
- lpsz: LPTSTR;
- cch: UINT;
- ulFlags: ULONG): HResult;
- begin
- Result := S_FALSE;
- end;
-
-
- function TExchExt.ResetToolbar(
- tbid: ULONG;
- ulFlags: ULONG): HResult;
- begin
- Result := S_FALSE;
- end;
-
-
-
- end.
-